import React, { Component } from 'react'

export default class Details extends Component {

    state = {
        details: [
            {id:'01',comment:'你好，我的祖国'},
            {id:'02',comment:'你好，我的妈妈'},
            {id:'03',comment:'你好，我的电脑'}
        ]
    }

    render() {
        console.log('this.props',this.props)
        const {details} = this.state;
        const {params} = this.props.match;
        const detailofMessage = details.find((detailObj)=>{
            return detailObj.id === params.id 
        })
        return (
            <ul>
                <li>ID: {detailofMessage.id}</li>
                <li>Title: {params.title}</li>
                <li>Comment: {detailofMessage.comment}</li>
            </ul>
        )
    }
}
